package com.hfut.jpoa.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hfut.jpoa.common.dto.ResultDto;
import com.hfut.jpoa.dao.BusinessInfoDAO;
import com.hfut.jpoa.dto.BusinessInfoDTO;
import com.hfut.jpoa.model.BusinessInfo;
import com.hfut.jpoa.service.BusinessInfoService;
import com.hfut.jpoa.service.exception.BusinessInfoException;

public class BusinessInfoServiceImpl implements BusinessInfoService
{
	private static final Logger LOGGER = LoggerFactory
	        .getLogger(BusinessInfoServiceImpl.class);

	BusinessInfoDAO dao;

	public ResultDto<BusinessInfo> queryInfoForPage(BusinessInfoDTO condition)
	        throws BusinessInfoException
	{
		ResultDto<BusinessInfo> findInfoForPage = dao
		        .findInfoForPage(condition);
		return findInfoForPage;
	}

	public void update(BusinessInfo record) throws BusinessInfoException
	{
		dao.updateByPrimaryKeySelective(record);
	}

	public BusinessInfo findInfo(BusinessInfo condition)
	        throws BusinessInfoException
	{
		return dao.selectByPrimaryKey(condition.getBusinessInfoId());
	}

	public boolean codeValidator(BusinessInfo condition)
	        throws BusinessInfoException
	{
		// TODO Auto-generated method stub
		return false;
	}

	public List<BusinessInfo> queryList(BusinessInfo condition)
	        throws BusinessInfoException
	{
		// TODO Auto-generated method stub
		return null;
	}

	public void saveBusinessInfo(BusinessInfo BusinessInfo)
	        throws BusinessInfoException
	{
		if (null == BusinessInfo)
		{
			LOGGER.error("BusinessInfo is empty.");
			throw new BusinessInfoException("BusinessInfo info is empty");
		}
		BusinessInfo.setResult("0");
		dao.insert(BusinessInfo);

	}

	public int delete(BusinessInfo BusinessInfo) throws BusinessInfoException
	{
		return dao.deleteByPrimaryKey(BusinessInfo.getBusinessInfoId());
	}

	public BusinessInfoDAO getDao()
	{
		return dao;
	}

	public void setDao(BusinessInfoDAO dao)
	{
		this.dao = dao;
	}

}
